<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="main :: common_head">
    <style>
        .changeI {
            display: block;
            width: 100%;
            height: 100%;
        }

        ul li {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .navbar .nav > li > .dropdown-menu::before {
            display: none !important;
        }

        .navbar .nav > li > .dropdown-menu::after {
            display: none !important;
        }

        .dropdown-menu:hover, .dropdown-menu:hover {
            display: none !important;
        }

        .dropdown-menu:hover::before, .dropdown-menu:hover::after {
            display: none !important;
        }

        #myli > ul:hover::before {
            display: none;
        }

        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body>
<!--删除提示模态框-->
<div class="modal fade" id="delcfmModel1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body">是否要删除？</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="deleteEdgeById()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--删除提示模态框结束-->
<!--删除设备失败提示模态框-->
<div class="modal fade" id="delcfmModel11" tabindex="-1" role="dialog" aria-labelledby="myModalLabel11" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel11">提示</h4>
            </div>
            <div class="modal-body">该基础策略已在组合策略中使用，不允许删除！</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--删除设备失败提示模态框结束-->

<div class="container-fluid-full">
    <div class="row-fluid">

        <noscript>
            <div class="alert alert-block span10">
                <h4 class="alert-heading">Warning!</h4>
                <p>You need to have <a href="" target="_blank">JavaScript</a> enabled to use this site.</p>
            </div>
        </noscript>

        <!-- start: Content -->
        <div id="content" class="span10" style="width: 100%;">
            <ul class="breadcrumb" th:if="${#request.getParameter('breadcrumb') == 'true'}">
                <li>
                    <i class="fas fa-circle-notch"></i>
                    <a id="home" href="#" onclick="parent.location.reload()">主页</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">策略库展示</a></li>
            </ul>
            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header" data-original-title>
                        <h2><i class="halflings-icon white user"></i><span class="break"></span>策略库展示</h2>
                        <div class="box-icon"></div>
                    </div>
                    <div class="box-content">
                        <!-- 下拉菜单开始-->
                        <div class="container" style="margin-left: 0px">
                            <ul id="mytab" class="nav nav-pills nav-justified" style="margin-left: 0px">
                                <li role="presentation" class="dropdown" id="myli" style="float: left;">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" th:unless="${graphId}" style="border:1px solid black">请选择图谱<span class="caret"></span></a>
                                    <div th:each="graph,graphStat:${graphInfoList}" class="dropdown">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" th:if="${graphId == graph.graphId}" th:text="${graph.graphName}" style="padding:5px 12px; text-decoration:none; line-height: 32px; border:1px solid black; border-radius:5px">
                                            <span class="caret"></span></a>
                                    </div>
                                    <ul class="dropdown-menu">
                                        <li th:each="graph,graphStat:${graphInfoList}">
                                            <a th:href="@{/relationship/viewRelationship/}+${graph.graphId}" th:text="${graph.graphName}"></a>
                                        </li>
                                    </ul>
                                </li>
                                <div class="container" style="margin-left: 20px; float: left; width: 100px">
                                    <a class="btn btn-primary" th:href="@{/relationship/add/}+${graphId}" style="display: none;">添加策略</a>
                                </div>
                            </ul>
                        </div>
                        <!-- 下拉菜单结束-->
                        <table class="table table-striped table-bordered bootstrap-datatable datatable">
                            <thead>
                            <tr>
                                <th>基础策略ID</th>
                                <th>源设备名</th>
                                <th>目标设备名</th>
                                <th>损耗率</th>
                                <th>能源属性</th>
                                <th>所属图谱</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="relationEdge:${relationshipList}">
                                <td th:text="${relationEdge.id}"></td>
                                <td class="center" th:text="${relationEdge.deviceFromName}"></td>
                                <td class="center" th:text="${relationEdge.deviceToName}"></td>
                                <td class="center" th:text="${relationEdge.lossRate}"></td>
                                <td class="center" th:text="${relationEdge.typeName}"></td>
                                <td class="center" th:text="${relationEdge.graphName}"></td>
                                <td class="center">
                                    <a class="btn btn-info" title="修改"
                                       th:href="@{/relationship/get/}+${relationEdge.id}">
                                        修改
                                    </a>
                                    <a class="btn btn-danger" href="#" title="删除" th:id="${relationEdge.id}"
                                       onclick="deleteEdge()">删除</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div><!--/.fluid-container-->
        <!-- end: Content -->
    </div><!--/#content.span10-->
</div><!--/fluid-row-->

<div class="modal hide fade" id="myModal">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Settings</h3>
    </div>
    <div class="modal-body">
        <p>Here settings can be configured...</p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">Close</a>
        <a href="#" class="btn btn-primary">Save changes</a>
    </div>
</div>

<div class="common-modal modal fade" id="common-Modal1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-content">
        <ul class="list-inline item-details">
            <li><a href="http://sc.chinaz.com">Admin templates</a></li>
            <li><a href="http://sc.chinaz.com">Bootstrap themes</a></li>
        </ul>
    </div>
</div>

<div class="clearfix"></div>

<div th:replace="main::common_js"></div>

<script>
    breadcrumb()
    window.onload = function() {
        parent.modifyTitle('基础策略管理')
    }
</script>

<script th:src="@{/js/detect-element-resize.js}"></script>
<script th:src="@{/js/iframe-resize.js}"></script>

<script>
    // 获取当前点击的设备菜单，添加高亮显示
    var deleteEdgeId = "";
    $(document).ready(function () {
        var location=window.location.href;//获取网页地址
        var id=location.substring(location.lastIndexOf('/')+1);//获取/后的id
        if (id.lastIndexOf('?') != -1) {
            id = id.substring(0, id.lastIndexOf('?'))
        }
        $("#"+"li"+id).addClass("active").siblings().removeClass("active");//对应li高亮
        // $(".active a")[0].click()
    })

    //删除边，弹出模态框提示
    function deleteEdge() {
        $("#delcfmModel1").modal("show");
        deleteEdgeId = $(event.target).attr("id");
        console.log(deleteEdgeId);
    }

    //模态框确认删除
    function deleteEdgeById() {
        $.ajax({
            type: "GET",
            url: "/multipower/relationship/delete/" + deleteEdgeId,
            success: function (data) {
                $("#delcfmModel1").modal("hide"); //模态框隐藏
                if(data.status == 1){
                    location.reload();
                }else {
                    $("#delcfmModel11").modal("show");
                }
            }
        })
    }
</script>

</body>
</html>
